<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <div id="root"></div>

  <script crossorigin src="https://unpkg.com/react@18.3.1/umd/react.development.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.development.js"></script>
  <script crossorigin src="https://unpkg.com/babel-standalone@6.26.0/babel.min.js"></script>

  <script type="text/babel">

    // 1.创建root
    const root = ReactDOM.createRoot(document.querySelector('#root'))

    // 封装App组件
    class App extends React.Component {
      constructor() {
        super()

        this.state = {
          movies: ['大话西游', '流浪地球', '美人鱼']
        }
      }

      render() {
        let liEls = []
        for (let i = 0; i < this.state.movies.length; i++) {
          let liEl = <li>{this.state.movies[i]}</li>
          liEls.push(liEl)
        }
        return (
          <div>
            <h2>电影列表</h2>
            <ul>
              {liEls}
              {this.state.movies.map((i) => <li>{i}</li>)}
            </ul>
          </div>
        )
      }
    }

    // 2.渲染组件
    // jsx => React.createElement
    root.render(<App />)
  </script>

</body>
</html>